<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../org/angular.min.js"></script>
</head>

<body ng-app="app">
    <!-- 控制器一 -->
    <div ng-controller="ctrl">
        <table width="500" border="1">
            <tr>
                <th>网站</th>
                <th>url</th>
            </tr>
            <tr ng-repeat="d in data">
                <td>{{d.title}}</td>
                <td>{{d.url}}</td>
            </tr>
        </table>
    </div>
    <hr />
    <script>
        var m = angular.module('app', []);
        //创建一个获取数据的服务
        m.service('webService', ['$http', function($http) {
            this.get = function() {
                return $http.get('1.php', {
                    cache: true
                }).then(function(res) {
                    return res.data;
                })
            }
        }])
        m.controller('ctrl', ['$scope', 'webService', function($scope, webService) {
            webService.get().then(function(data) {
                $scope.data = data;
                console.log(data);
            });
        }])
    </script>
</body>

</html>
